/**
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 */
export var moveZeroes = function (nums) {
  let left = 0
  let right = 0
  while (right < nums.length) {
    if (nums[right] != 0) {
      const temp = nums[left]
      nums[left] = nums[right]
      nums[right] = temp
      left++
    }
    right++
  }
}

/**
 * Array.sort方法
 *
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 */
export var moveZeroes2 = function (nums) {
  nums.sort((a, b) => (b ? 0 : -1))
  //  b为第一个元素，a为第二个元素, 当b为0时, 返-1, b放在a的后面。
}
